﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace WindowsGame1
{
    class Jogo3
    {
        //char ch;
        int Restante;
        bool apertado;
        public Jogo3()
        {
            Restante = 50;
            apertado = false;
           // Random _r = new Random();
           // ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * _r.NextDouble() + 65)));
        }

        public void Reseta()
        {
            Restante = 50;
            apertado = false;
        }

        public char Update(KeyboardState ks, Tempo Time, Song[] Musicas)
        {
            if (Time.tempoRestante <= TimeSpan.FromSeconds(0))
            {
                MediaPlayer.Play(Musicas[2]);
                Time.tempoRestante = TimeSpan.FromSeconds(5);
                return '0';
            }
            if (Restante <= 0)
            {
                Time.ConverteTempo();
                Time.ResetaTempo();
                return '4';
            }
            if (ks.IsKeyUp(Keys.J))
            {
                apertado = false;
            }
            if (ks.IsKeyDown(Keys.J) && apertado == false)
            {
                apertado = true;
                //if (Time.Total.Milliseconds % 30 == 0)
                //{
                    Restante--;
                //}
            }
            return '3';
        }

        public void Draw(SpriteBatch spriteBatch, SpriteFont font)
        {
            string xpto = "YOU MUST PRESS 'J' " + Restante.ToString() + " TIMES!";
            spriteBatch.DrawString(font, xpto, new Vector2(50, 768/2), Color.Red);
        }
    }
}
